/*
 * ShareAreaResultBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-11
 */

package com.bjtech.domain.query;

import java.util.Date;

import org.ssi.web.util.QuerySpecTpl;

import com.bjtech.web.util.SelectBean;

/**
 * 功能概述:分摊域分摊结果 <br>
 * 
 * @author 王峰
 */

public class ShareAreaResultQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private Long area_id;
	/* */
	private String share_name;
	/* */
	private Date start_date;
	private Date b_start_date;
	private Date e_start_date;
	/* */
	private Date end_date;
	private Date b_end_date;
	private Date e_end_date;
	/* */
	private Float base_price;
	/* */
	private Float cal_price;
	/* */
	private Float price_area;
	/* */
	private Long sum_user;
	/* */
	private Float sum_area;
	/* */
	private Long sum_other_user;
	/* */
	private Long sum_other_area;
	/* */
	private Float sum_heat;
	/* */
	private Double sum_base_money;
	/* */
	private Double sum_cal_money;
	/* */
	private Double sum_heat_money;
	/* */
	private Float sum_other_heat_money;
	/* */
	private Float sum_share_money;
	/* */
	private Long sum_sink_weight;
	/* */
	private Float per_weight_price;
	/* */
	private Long share_meter_num;
	/* */
	private Long sink_num;
	/* */
	private Float avg_heat_target;
	/* */
	private Long share_type;
	/* */
	private String share_man;
	/* */
	private Date share_date;
	private Date b_share_date;
	private Date e_share_date;
	/* */
	private String demo;
	
	private int have_shared;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(area_id)) {
				fromPart.append(" and a.area_id = ");
				fromPart.append(area_id);
			}

			if (QuerySpecTpl.isValid(share_name)) {
				fromPart.append(" and a.share_name like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(share_name);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(start_date)) {
				fromPart
						.append(" and str_to_date(a.start_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(start_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_start_date)) {
				fromPart
						.append(" and str_to_date(a.start_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_start_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_start_date)) {
				fromPart
						.append(" and str_to_date(a.start_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_start_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(end_date)) {
				fromPart
						.append(" and str_to_date(a.end_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(end_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_end_date)) {
				fromPart
						.append(" and str_to_date(a.end_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_end_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_end_date)) {
				fromPart
						.append(" and str_to_date(a.end_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_end_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(base_price)) {
				fromPart.append(" and a.base_price = ");
				fromPart.append(base_price);
			}

			if (QuerySpecTpl.isValid(cal_price)) {
				fromPart.append(" and a.cal_price = ");
				fromPart.append(cal_price);
			}

			if (QuerySpecTpl.isValid(price_area)) {
				fromPart.append(" and a.price_area = ");
				fromPart.append(price_area);
			}

			if (QuerySpecTpl.isValid(sum_user)) {
				fromPart.append(" and a.sum_user = ");
				fromPart.append(sum_user);
			}

			if (QuerySpecTpl.isValid(sum_area)) {
				fromPart.append(" and a.sum_area = ");
				fromPart.append(sum_area);
			}

			if (QuerySpecTpl.isValid(sum_other_user)) {
				fromPart.append(" and a.sum_other_user = ");
				fromPart.append(sum_other_user);
			}

			if (QuerySpecTpl.isValid(sum_other_area)) {
				fromPart.append(" and a.sum_other_area = ");
				fromPart.append(sum_other_area);
			}

			if (QuerySpecTpl.isValid(sum_heat)) {
				fromPart.append(" and a.sum_heat = ");
				fromPart.append(sum_heat);
			}

			if (QuerySpecTpl.isValid(sum_base_money)) {
				fromPart.append(" and a.sum_base_money = ");
				fromPart.append(sum_base_money);
			}

			if (QuerySpecTpl.isValid(sum_cal_money)) {
				fromPart.append(" and a.sum_cal_money = ");
				fromPart.append(sum_cal_money);
			}

			if (QuerySpecTpl.isValid(sum_heat_money)) {
				fromPart.append(" and a.sum_heat_money = ");
				fromPart.append(sum_heat_money);
			}

			if (QuerySpecTpl.isValid(sum_other_heat_money)) {
				fromPart.append(" and a.sum_other_heat_money = ");
				fromPart.append(sum_other_heat_money);
			}

			if (QuerySpecTpl.isValid(sum_share_money)) {
				fromPart.append(" and a.sum_share_money = ");
				fromPart.append(sum_share_money);
			}

			if (QuerySpecTpl.isValid(sum_sink_weight)) {
				fromPart.append(" and a.sum_sink_weight = ");
				fromPart.append(sum_sink_weight);
			}

			if (QuerySpecTpl.isValid(per_weight_price)) {
				fromPart.append(" and a.per_weight_price = ");
				fromPart.append(per_weight_price);
			}

			if (QuerySpecTpl.isValid(share_meter_num)) {
				fromPart.append(" and a.share_meter_num = ");
				fromPart.append(share_meter_num);
			}

			if (QuerySpecTpl.isValid(sink_num)) {
				fromPart.append(" and a.sink_num = ");
				fromPart.append(sink_num);
			}

			if (QuerySpecTpl.isValid(avg_heat_target)) {
				fromPart.append(" and a.avg_heat_target = ");
				fromPart.append(avg_heat_target);
			}

			if (QuerySpecTpl.isValid(share_type)) {
				fromPart.append(" and a.share_type = ");
				fromPart.append(share_type);
			}

			if (QuerySpecTpl.isValid(share_man)) {
				fromPart.append(" and a.share_man like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(share_man);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(share_date)) {
				fromPart
						.append(" and str_to_date(a.share_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(share_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_share_date)) {
				fromPart
						.append(" and str_to_date(a.share_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_share_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_share_date)) {
				fromPart
						.append(" and str_to_date(a.share_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_share_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(have_shared)) {
				if(have_shared==1){
					fromPart.append(" and a.share_date is not null ");
				}
				if(have_shared==2){
					fromPart.append(" and a.share_date is null ");
				}
			}
			
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}
			
			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("asc");

			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getArea_id() {
		return this.area_id;
	}

	public void setArea_id(Long area_id) {
		this.area_id = area_id;
	}

	public String getShare_name() {
		return this.share_name;
	}

	public void setShare_name(String share_name) {
		this.share_name = share_name;
	}

	public Date getStart_date() {
		return this.start_date;
	}

	public void setStart_date(Date start_date) {
		this.start_date = start_date;
	}

	public Date getB_start_date() {
		return this.b_start_date;
	}

	public void setB_start_date(Date b_start_date) {
		this.b_start_date = b_start_date;
	}

	public Date getE_start_date() {
		return this.e_start_date;
	}

	public void setE_start_date(Date e_start_date) {
		this.e_start_date = e_start_date;
	}

	public Date getEnd_date() {
		return this.end_date;
	}

	public void setEnd_date(Date end_date) {
		this.end_date = end_date;
	}

	public Date getB_end_date() {
		return this.b_end_date;
	}

	public void setB_end_date(Date b_end_date) {
		this.b_end_date = b_end_date;
	}

	public Date getE_end_date() {
		return this.e_end_date;
	}

	public void setE_end_date(Date e_end_date) {
		this.e_end_date = e_end_date;
	}

	public Float getBase_price() {
		return this.base_price;
	}

	public void setBase_price(Float base_price) {
		this.base_price = base_price;
	}

	public Float getCal_price() {
		return this.cal_price;
	}

	public void setCal_price(Float cal_price) {
		this.cal_price = cal_price;
	}

	public Float getPrice_area() {
		return this.price_area;
	}

	public void setPrice_area(Float price_area) {
		this.price_area = price_area;
	}

	public Long getSum_user() {
		return this.sum_user;
	}

	public void setSum_user(Long sum_user) {
		this.sum_user = sum_user;
	}

	public Float getSum_area() {
		return this.sum_area;
	}

	public void setSum_area(Float sum_area) {
		this.sum_area = sum_area;
	}

	public Long getSum_other_user() {
		return this.sum_other_user;
	}

	public void setSum_other_user(Long sum_other_user) {
		this.sum_other_user = sum_other_user;
	}

	public Long getSum_other_area() {
		return this.sum_other_area;
	}

	public void setSum_other_area(Long sum_other_area) {
		this.sum_other_area = sum_other_area;
	}

	public Float getSum_heat() {
		return this.sum_heat;
	}

	public void setSum_heat(Float sum_heat) {
		this.sum_heat = sum_heat;
	}

	public Double getSum_base_money() {
		return this.sum_base_money;
	}

	public void setSum_base_money(Double sum_base_money) {
		this.sum_base_money = sum_base_money;
	}

	public Double getSum_cal_money() {
		return this.sum_cal_money;
	}

	public void setSum_cal_money(Double sum_cal_money) {
		this.sum_cal_money = sum_cal_money;
	}

	public Double getSum_heat_money() {
		return this.sum_heat_money;
	}

	public void setSum_heat_money(Double sum_heat_money) {
		this.sum_heat_money = sum_heat_money;
	}

	public Float getSum_other_heat_money() {
		return this.sum_other_heat_money;
	}

	public void setSum_other_heat_money(Float sum_other_heat_money) {
		this.sum_other_heat_money = sum_other_heat_money;
	}

	public Float getSum_share_money() {
		return this.sum_share_money;
	}

	public void setSum_share_money(Float sum_share_money) {
		this.sum_share_money = sum_share_money;
	}

	public Long getSum_sink_weight() {
		return this.sum_sink_weight;
	}

	public void setSum_sink_weight(Long sum_sink_weight) {
		this.sum_sink_weight = sum_sink_weight;
	}

	public Float getPer_weight_price() {
		return this.per_weight_price;
	}

	public void setPer_weight_price(Float per_weight_price) {
		this.per_weight_price = per_weight_price;
	}

	public Long getShare_meter_num() {
		return this.share_meter_num;
	}

	public void setShare_meter_num(Long share_meter_num) {
		this.share_meter_num = share_meter_num;
	}

	public Long getSink_num() {
		return this.sink_num;
	}

	public void setSink_num(Long sink_num) {
		this.sink_num = sink_num;
	}

	public Float getAvg_heat_target() {
		return this.avg_heat_target;
	}

	public void setAvg_heat_target(Float avg_heat_target) {
		this.avg_heat_target = avg_heat_target;
	}

	public Long getShare_type() {
		return this.share_type;
	}

	public void setShare_type(Long share_type) {
		this.share_type = share_type;
	}

	public String getShare_man() {
		return this.share_man;
	}

	public void setShare_man(String share_man) {
		this.share_man = share_man;
	}

	public Date getShare_date() {
		return this.share_date;
	}

	public void setShare_date(Date share_date) {
		this.share_date = share_date;
	}

	public Date getB_share_date() {
		return this.b_share_date;
	}

	public void setB_share_date(Date b_share_date) {
		this.b_share_date = b_share_date;
	}

	public Date getE_share_date() {
		return this.e_share_date;
	}

	public void setE_share_date(Date e_share_date) {
		this.e_share_date = e_share_date;
	}

	public String getDemo() {
		return this.demo;
	}

	public void setDemo(String demo) {
		this.demo = demo;
	}

	public int getHave_shared() {
		return have_shared;
	}

	public void setHave_shared(int haveShared) {
		have_shared = haveShared;
	}
}
